<!DOCTYPE html>
<html>

  <head>
    <!-- Styles -->
    <link rel="stylesheet" href="/pkce-realcase/css/bael-oauth-pkce-styles.css">
    <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">

    <!-- Import the React, React-Dom and Babel libraries -->
    <!-- Note: Here we are using React's unminified-development version -->
    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

    <!-- Axios to make requests easily -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>

  <body>
    <div id="root"></div>
    <script type="text/javascript" src="/common/js/provider_configs.js"></script>
    <script type="text/javascript" src="/common/js/common_functions.js"></script>
    <script type="text/babel" src="/pkce-realcase/js/components/popup/popup_window.js"></script>
    <script type="text/babel">
      const parentWindow = window.opener || window.parent;
      const typeOfWindow = (window.opener && 'popup') || (window.parent && 'iframe');
      const urlParams = new URLSearchParams(window.location.search);
      const popupProps = {
        authCode: urlParams.get('code'),
        state: urlParams.get('state'),
        error: urlParams.get('error'),
        errorDescription: urlParams.get('error_description'),
        parentWindow,
        typeOfWindow
      }

      // popup rendering:
      const rootElement = document.getElementById('root');
      ReactDOM.render(<PopupWindow {...popupProps} />, rootElement);
    </script>
  </body>

</html>